/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fy.form.groovy;

import com.seeyon.apps.collaboration.po.ColSummary;
import com.seeyon.ctp.form.bean.FormTriggerBean;
import com.seeyon.ctp.form.modules.trigger.FormTriggerManager;
import com.seeyon.ctp.services.UserToken;
import com.seeyon.v3x.services.AuthorityService;
import com.seeyon.v3x.services.V3XLocator;
import com.seeyon.v3x.services.document.DocumentService;
import com.seeyon.v3x.services.flow.FlowService;
import com.seeyon.v3x.services.flow.impl.FlowServiceImpl;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Administrator
 */
public class FormReaderFunc10{

    private static final Log logger = LogFactory.getLog(FormReaderFunc10.class);

    public static String getFlow(Object object) {
        String result = "";
        AuthorityService as;
        try {
            as = V3XLocator.getInstance().lookup(AuthorityService.class);

            UserToken token = as.authenticate("service-admin", "123456");
            logger.info("result:" + token);
            logger.info("result:" + token.getId());

            DocumentService ds = V3XLocator.getInstance().lookup(DocumentService.class);

            result = ds.exportFlow2(token.getId(), 6941744530972217114L);

            logger.info("result:" + result);

        } catch (Exception ex) {
            ex.printStackTrace();
            logger.error(ex);
        }
        return result;
    }

    public static String getFlow1(Object object) {
//        ColSummary s;
        String result = "";
        AuthorityService as;
        try {
//            FormTriggerManager frm = V3XLocator.getInstance().lookup(FormTriggerManager.class);
//            frm.doTrigger(null, i, l, FormTriggerBean.TriggerConditionState.FlowSend)
            
//            as = V3XLocator.getInstance().lookup(AuthorityService.class);
//
//            UserToken token = as.authenticate("service-admin", "123456");
//
//            FlowService fs = V3XLocator.getInstance().lookup(FlowService.class);
////            result = ds.exportFlow2(token.toString(), 6941744530972217114L);
//            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
//                    + "<formExport version=\"2.0\">\n"
//                    + "    <summary id=\"-1\" name=\"formmain_3981\"/>\n"
//                    + "    <values>\n"
//                    + "        <column name=\"人员选择器\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"部门选择器\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"单位选择器\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"子公司\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"日期\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"单据编号\">\n"
//                    + "            <value><![CDATA[20151200040]]></value>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"出门业务种类\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"出门业务种类其他\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"联系电话\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"出厂门\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"车号\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"出厂原因\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"特证单位\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"票证号\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"已返还次数\">\n"
//                    + "            <value>2</value>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"本次返还次数\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"是否存在未返厂物资\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"返还关联表单\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"状态_抓取存在未返厂物资数据\">\n"
//                    + "            <value>1</value>\n"
//                    + "        </column>\n"
//                    + "        <column name=\"单据编号1\">\n"
//                    + "            <value/>\n"
//                    + "        </column>\n"
//                    + "    </values>\n"
//                    + "</formExport>\n"
//                    + "";
//
//            ServiceResponse t = fs.launchFormCollaboration(token.getId(), "002218", "o_r_01", "测试", xml, new Long[]{}, "1", null);
//
//            logger.info("result:" + t.getResult());
//
//            logger.info("result:" + result);

        } catch (Exception ex) {
            ex.printStackTrace();
            logger.error(ex);
        }
        return result;
    }
}
